package hotel_price;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONReader;

import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;

public class FileTest {
    public static void main(String[] args) throws Exception {
        JSONReader reader = new JSONReader(new FileReader("D:\\MP\\宾馆的平均价\\input\\hongkong.txt"));
        BufferedWriter bw = new BufferedWriter(new FileWriter("D:\\MP\\宾馆的平均价\\input\\hongkong.json"));
        reader.startArray();
        Hotel hotel;
        while (reader.hasNext()) {
            hotel = reader.readObject(Hotel.class);
            String json = JSON.toJSONString(hotel);
            bw.write(json);
            bw.write("\n");
            bw.flush();
        }
        reader.endArray();
        bw.close();
    }
}
